package com.example.simplesvc;


import com.example.simplesvc.event.ReconciliationEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ReconciliationService {


    private static Logger log = LoggerFactory.getLogger(ReconciliationService.class);

    @Autowired
    ApplicationContext ctx;




    public ResponseEntity reconciliation() {




        //对账开始 通知相关方
        ReconciliationEvent evt = new ReconciliationEvent(ctx);
        ctx.publishEvent(evt);

        ////
        try {
            log.info("start reconciliation....");
            Thread.sleep(3000);
        }catch (Exception e) {
            //
        }
        //对账结束 通知相关方
        evt.finished();
        ctx.publishEvent(evt);

        return ResponseEntity.ok("success");

    }
}
